import {lazy, Suspense} from 'react'
import {Navigate} from 'react-router-dom'

import AuthComponent from './AuthComponent'

var Index = lazy(()=>import('../views/Index'))
var Login = lazy(()=>import('../views/Login'))
var NotFound = lazy(()=>import('../views/NotFound'))

var Admin = lazy(()=>import('../views/Index/Admin'))
var Command = lazy(()=>import('../views/Index/Command'))
var Echarts = lazy(()=>import('../views/Index/Echarts'))
var Editor = lazy(()=>import('../views/Index/Editor'))
var Excel = lazy(()=>import('../views/Index/Excel'))
var Home = lazy(()=>import('../views/Index/Home'))
var Pro = lazy(()=>import('../views/Index/Pro'))
var SecKill = lazy(()=>import('../views/Index/Seckill'))
var Search = lazy(()=>import('../views/Index/Search'))
var Map = lazy(()=>import('../views/Index/Map'))
var Swiper = lazy(()=>import('../views/Index/Swiper'))
var SwiperAdd = lazy(()=>import('../views/Index/SwiperAdd'))

//配置路由表
export default [
    {
        path:'/index',
        element: <Index />,
        children:[
            {
                path:'/index/home',
                element:<Suspense><Home /> </Suspense>,
            },
            {
                path:'/index/swiper',
                element:<AuthComponent perm='1-1'><Swiper /></AuthComponent>,
            },
            {
                path:'/index/swiperadd',
                element:<SwiperAdd /> ,
            },
            {
                path:'/index/admin',
                element:<AuthComponent perm='2-1 '><Admin /></AuthComponent> ,
            },
            {
                path:'/index/pro',
                element:<AuthComponent perm='3-1'><Pro /></AuthComponent>,
            },
            {
                path:'/index/seckill',
                element:<AuthComponent perm='3-2'><SecKill /></AuthComponent> ,
            },
            {
                path:'/index/command',
                element:<AuthComponent perm='3-3'><Command /></AuthComponent> ,
            },
            {
                path:'/index/search',
                element: <AuthComponent perm='3-4'><Search /></AuthComponent> ,
            },
            {
                path:'/index/echarts',
                element:<AuthComponent perm='4-1'><Echarts /></AuthComponent>,
            },
            {
                path:'/index/editor',
                element: <AuthComponent perm='5-1'><Editor /></AuthComponent>,
            },
            {
                path:'/index/excel',
                element:<AuthComponent perm='6-1'><Excel /></AuthComponent> ,
            },
            {
                path:'/index/map',
                element:<AuthComponent perm='7-1'><Map /></AuthComponent>,
            },
            {
                path:'/index',
                element: <Navigate to="/index/home" />,
            },
            {
                path:'*',
                element: <NotFound />,
            }
        ]
    },
    {
        path:'/login',
        element: <Login />,
    },
    {
        path:'/',
        element: <Navigate to="/index" />,
    },
    {
        path:'*',
        element: <NotFound />,
    }
]